#!/usr/bin/env python
#-*-coding:utf-8-*-

# "error.py" is part of Tarinca-COA (http://code.google.com/p/taringa-api/)
# Copyright (C) - 2010 Juan B Cabral <jbc dot develop at gmail dot com>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


################################################################################
# DOCS
################################################################################

"""Wrapper para los errores de Taringa"""

################################################################################
# META
################################################################################

__version__ = "0.2"
__license__ = "LGPL3"
__author__ = "JBC"
__since__ = "0.2"
__date__ = "2010-02-03"

################################################################################
# TARINGA ERROR WRAPPER
################################################################################

class TaringaError(Exception):
    """Wrapper para los errores de Taringa.
    
    Errores:
        code 0: Invalid Response 
        
        code 1: Method missing 
        code 2: Invalid API key 
        code 3: Invalid format 
        code 4: Invalid method 
        code 5: Missing parameters 
        code 6: Bad User nickname 
        code 7: Invalid parameter 
        code 8: No data 
        code 9: Post deleted 
        code 10: Private post 
        code 11: Rate Limiting Exceeded 
        
        code 1000 : Unknown error
    
    """
    def __init__(self, msg, code):
        super(TaringaError, self).__init__()
        self.msg = msg
        self.code = int(code)
        
    def __repr__(self):
        return str(self)
    
    def __str__(self):
        return "%s - Error Code: %i" % (self.msg, self.code)

    
################################################################################
# MAIN
################################################################################

if __name__ == '__main__':
    print(__doc__)
